/**
 * Copyright (C) 2017-2018 pinganfang, Inc. All Rights Reserved.
 */
package com.pingan.haofang.searchcloud.api.matedata;

import com.pingan.haofang.searchcloud.api.matedata.constant.MetadataFieldType;

/**
 * @author huhailiang937
 * @date 2017年5月15日下午5:28:53
 * @since 1.0.0
 */
public class FieldMeta {

    private boolean isPk;

    private boolean required;
    
    private String name;

    private boolean multiValued;

    private boolean indexed;
    
    private MetadataFieldType type;

    private boolean versionKey;

    public FieldMeta() {
    }

    public FieldMeta(String name, MetadataFieldType type) {
        this.name = name;
        this.type = type;
    }

    public FieldMeta name(String n){
        this.name = n;
        return this;
    }

    public FieldMeta multiValued(boolean multiValued) {
        this.multiValued = multiValued;
        return this;
    }


    public FieldMeta pk(){
        this.isPk = true;
        return this;
    }
    
    public FieldMeta type(MetadataFieldType t){
        this.type = t;
        return this;
    }
    
    
    /**
     * @return the isPk
     */
    public boolean isPk() {
        return isPk;
    }

    /**
     * @param isPk the isPk to set
     */
    public void setPk(boolean isPk) {
        this.isPk = isPk;
    }

    public boolean isRequired() {
        return required;
    }

    public void setRequired(boolean required) {
        this.required = required;
    }

    /**
     * @return the name
     */
    public String getName() {
        return name;
    }

    /**
     * @param name the name to set
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * @return the type
     */
    public MetadataFieldType getType() {
        return type;
    }

    /**
     * @param type the type to set
     */
    public void setType(MetadataFieldType type) {
        this.type = type;
    }

    public boolean isMultiValued() {
        return multiValued;
    }

    public void setMultiValued(boolean multiValued) {
        this.multiValued = multiValued;
    }

    public boolean isIndexed() {
        return indexed;
    }
    public boolean isNotIndexed() {
        return !indexed;
    }
    public void setIndexed(boolean indexed) {
        this.indexed = indexed;
    }

    public boolean isVersionKey() {
        return versionKey;
    }

    public void setVersionKey(boolean versionKey) {
        this.versionKey = versionKey;
    }
}
